home *** CD-ROM | disk | FTP | other *** search
/ Network Support Library / RoseWare - Network Support Library.iso / apidev / batuti.arc / SETCDR.C < prev    next >
Text File  |  1990-01-11  |  946b  |  45 lines

  1. /*
  2.  *
  3.  *   setcdr -- sets the environment variable name in arg[1] to the current
  4.  *   drive specifier.
  5.  *   Richard Connelly,(C) 1989,1990
  6.  *
  7.  */
  8.  
  9. #include <stdio.h>
  10. #include <conio.h>
  11. #include <process.h>
  12. #include <dos.h>
  13. #include <dir.h>
  14. #include <mem.h>
  15. #include <string.h>
  16. #include "mst_env.h"
  17.  
  18. #define buflen 256
  19.  
  20. void main(int argc, char *argv[])
  21. {
  22.  
  23. /*
  24.  *         Determine if the user is using the command correctly
  25.  */
  26.  
  27.    char buf[buflen];
  28.  
  29.    if (argc == 1)
  30.    {
  31.       fprintf(stderr," usage:\n\t  setcdr env-name  \n");
  32.       exit(-1);
  33.     }
  34.  
  35. /*
  36.  *         Set the current drive spec. to an environment variable provided via argv
  37.  */
  38.                     /* set the environment var passed */
  39.       strcpy(buf," :");
  40.       buf[0]=getdisk()+'A';
  41.       if (m_putenv(argv[1],buf))
  42.      fprintf(stderr,"Out of environment space\n");
  43.       exit(0);                          /* by argv & terminate successfully */
  44. }
  45.